<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的收藏</title>
    <link rel="stylesheet" href="/stylesheets/personnal.css">
    <link rel="stylesheet" href="/stylesheets/xiuxiu.css">
    <!--<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>-->
    <script src="/js/jquery-1.8.3.js"></script>
</head>
<body>
<!--导航-->
    <%include nav.html%>
<div class="personnal_container">
    <div class="person_left">
        <div class="left_icon">
            <img src="/images/dog_icon.png" alt="" style="width: 120px;height: 120px">
        </div>
        <ul>
            <a href="/users"><li>查看用户信息</li></a>
            <a href="/users/apply_foster"><li>申请寄养家庭</li></a>
            <a href="/users/mypet"> <li>我的宠物</li></a>
            <a href="/users/collection"> <li class="bgcolor">宠物故事</li></a>
            <a href="/users/myorder"><li>我的订单</li></a>
        </ul>
    </div>
    <div class="person_right">
        <div class="editor_container">
            <div class="editor_header">
                <h3>我的文章</h3>
            </div>
            <div class="mycollection_container scrollbar">
                <%
                for(var i=0;i<=res.length-1;i++){
                %>
                <div class="collect_list ">
                    <div class="collect_info0">
                        <form class="delete">
                            <div class="he1_com he01" style="text-align: left">
                                文章编号：<input type="text" value="<%=res[i].artno%>" name="artno">
                            </div>
                            <div class="he1_com he02" style="text-align: right">
                                <input type="submit" value="删除" >
                            </div>
                        </form>
                    </div>
                    <div class="collect_info0">
                       <div class="he2">
                          发表时间： <span><%=res[i].date%></span>
                       </div>
                    </div>
                    <div class="collect_info0">
                        <div class="he3 he_com">
                            <img src="/images/<%=res[i].icon%>" alt="" class="business_icon">
                        </div>
                        <div class="he4 he_com">
                            <div class="he"><%=res[i].title%></div>
                            <div class="he" style="overflow: hidden"><%=res[i].content%></div>
                        </div>
                    </div>
                </div>
                <%
                }
                %>
            </div>
        </div>
    </div>
</div>
<%include footer.html%>

<script>

    $(function () {
        $('.delete').submit(function () {
            $.ajax({
                type:'post',
                url:'/users/collection',
                data:$(this).serialize(),
                timeout:3000,
                dataType:'json',
                success:function (data) {
                    if(data.res==1){
                        alert('删除成功');
                        location.href='/users/collection';
                    }else if(data.res==0){
                      alert('删除失败')
                    }
                },
                error:function (error) {
                    alert(error.message)

                }

            });
            return false;
        });

    });


</script>

<script>
    $(function(){
        $('.he2').find('span').each(function(){
            $(this).html(FormatDate ($(this).html()));
        });
    });
    function FormatDate (strTime) {
        var date = new Date(strTime);
        var month;
        var day;
        if(parseInt(date.getMonth())<9){
            month="0"+parseInt(date.getMonth()+1)
        }else{
            month=date.getMonth();
        }
        if(parseInt(date.getDate())<10){
            day="0"+date.getDate()
        }else{
            day=date.getDate();
        }

        return date.getFullYear()+"-"+month+"-"+day;
    }
</script>
</body>
</html>